using System;
using System.Drawing;
using System.ComponentModel;

namespace igp.net.DataModel
{
    /// <summary>
    /// Represents program settings.
    /// </summary>
    public class igpSettings
    {
        private double drawingDetails;

        /// <summary>
        /// Function drawing details. 1 - full detail. Minimum 0.01.
        /// </summary>
        [CategoryAttribute("Rendering"), DescriptionAttribute("Function drawing details. 1 - full detail. Minimum 0.01.")]
 
        public double DrawingDetails
        {
            get { return drawingDetails; }
            set { 
                drawingDetails = value;
                if (drawingDetails > 1) drawingDetails = 1;
                if (drawingDetails < 0.001) drawingDetails = 0.01;
            }
        }

        /// <summary>
        /// Gives access to the only existing instance of this class.
        /// </summary>
        public static igpSettings Singleton { get; private set; }

        /// <summary>
        /// Creates an instance of this class.
        /// </summary>
        /// <returns>Created instance.</returns>
        public static igpSettings create()
        {
            if (Singleton != null)
            {
                throw new Exception("You can create only one instance of this object!");
            }

            Singleton = new igpSettings();
            return Singleton;
        }

        private igpSettings()
        {
            ViewBorder = true;
            DrawingDetails = 0.2;
            EnableVisualStyles = true;
            ChartFont = new Font("Calibri", 8);
        }

        /// <summary>
        /// Enables/Disables visual style support.
        /// </summary>
        [CategoryAttribute("Appearance"),
         DescriptionAttribute(
             "Enables/Disables visual styles support. Change of this setting will take effect after program restart.")]
        public bool EnableVisualStyles { get; set; }

        /// <summary>
        /// Gets/Sets the visibility of the editor window.
        /// </summary>
        [CategoryAttribute("Windows"), DescriptionAttribute("Shows/Hides the editor window.")]
        public bool ShowEditor { get; set; }

        /// <summary>
        /// Gets/Sets the visibility of the picker window.
        /// </summary>
        [CategoryAttribute("Appearance"), DescriptionAttribute("Chart Font.")]
        public Font ChartFont { get; set; }

        /// <summary>
        /// Gets/Sets the visibility of the picker window.
        /// </summary>
        [CategoryAttribute("Windows"), DescriptionAttribute("Shows/Hides the picker window.")]
        public bool ShowPicker { get; set; }

        /// <summary>
        /// Enables/Disables a border of the rendered image.
        /// </summary>
        [CategoryAttribute("Appearance"),
         DescriptionAttribute("Enables/Disables the border around the image. The border is not rendered on the image.")]
        public bool ViewBorder { get; set; }

        /// <summary>
        /// Gives possibility to get/set smoothing mode.
        /// </summary>
        [CategoryAttribute("Rendering"), DescriptionAttribute("Changes rendering quality.")]
        public System.Drawing.Drawing2D.SmoothingMode DrawMode { get; set; }

        /// <summary>
        /// Picker window X position in pixels from left screen edge.
        /// </summary>
        [Browsable(false)]
        public int PickerWindowLeft { get; set; }

        /// <summary>
        /// PickerWindow Y position in pixels from top screen edge.
        /// </summary>
        [Browsable(false)]
        public int PickerWindowTop { get; set; }

        /// <summary>
        /// Picker window width in pixels.
        /// </summary>
        [Browsable(false)]
        public int PickerWindowWidth { get; set; }

        /// <summary>
        /// Picker window height in pixels.
        /// </summary>
        [Browsable(false)]
        public int PickerWindowHeight { get; set; }

        /// <summary>
        /// Editor window X position in pixels from left screen edge.
        /// </summary>
        [Browsable(false)]
        public int EditorWindowLeft { get; set; }

        /// <summary>
        /// Editor window X position in pixels from left screen edge.
        /// </summary>
        [Browsable(false)]
        public int EditorWindowTop { get; set; }

        /// <summary>
        /// Editor window height in pixels.
        /// </summary>
        [Browsable(false)]
        public int EditorWindowHeight { get; set; }
    }
}